package org.finesys.common.security.authorization;

import org.finesys.common.security.authentication.handler.AuthAuthenticationFailureHandler;
import org.finesys.common.security.authentication.handler.AuthAuthenticationSuccessHandler;
import org.springframework.security.config.Customizer;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2TokenEndpointConfigurer;

public class OAuth2TokenEndpointConfigurerCustomizer implements Customizer<OAuth2TokenEndpointConfigurer> {
    @Override
    public void customize(OAuth2TokenEndpointConfigurer oAuth2TokenEndpointConfigurer) {
        // // 注入自定义的授权认证
        oAuth2TokenEndpointConfigurer.accessTokenRequestConverter(AccessTokenRequestConverterCustomizer.customizer())
                // 登录成功处理器
                .accessTokenResponseHandler(new AuthAuthenticationSuccessHandler())
                .errorResponseHandler(new AuthAuthenticationFailureHandler())
        ;
    }
}
